package com.ankicoo.practice.daily;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 模糊坐标
 *
 * @author : QCYANG
 * @date : 2022/11/7 9:30
 */
public class LC816 {

    public static List<String> ambiguousCoordinates(String s) {
        List<String> result = new ArrayList<>();
        for (int i = 2; i < s.length()-1; i++) {
            List<String> s1 =  resultMatch(s.substring(1,i));
            List<String> s2 =  resultMatch( s.substring(i,s.length()-1));
            for(String a:s1){for(String b:s2){result.add("("+a+", "+b+")");}}
        }
        return result;
    }

    public static List<String> resultMatch(String s){
        List<String> doubleNum = new ArrayList<>();
        if(s.length()==1||s.charAt(0)!='0'){
            doubleNum.add(s);
        }
        for (int i = 1; i < s.length(); i++) {
            if ((i != 1 && s.charAt(0) == '0') || s.charAt(s.length() - 1) == '0') {
                continue;
            }
            doubleNum.add(s.substring(0, i) + "." + s.substring(i));
        }

        return doubleNum;
    }

    public static void main(String[] args) {
        String s = "(123)";
        List<String> result = ambiguousCoordinates(s);
        result.forEach(System.out::println);
    }
}
